#include<iostream>
#include <stack>
using namespace std;
 
char s[4] = { '0','A','B','C'};
stack<int> a[4];
 
void move(int now,int next){  
		a[next].push(a[now].top());
		printf("%d from %c to %c\n", a[now].top(),s[now], s[next]);
		a[now].pop();
}

int main() {
	int  n;
	cin >> n;
	for (int i = 0; i < n; i++)
		a[1].push(n - i);
	if (n%2 == 1) {
		s[2] = 'C'; 
		s[3] = 'B';
	}
	while (1) {
		int next; 
		for(int i=1;i<=3;i++)
			if(!a[i].empty()){
				if(a[i].top()==1){
					if(i==3) next=1;
					else next=i+1;
					move(i,next);
					break;
				}
			}
			
		if(a[2].size()==n || a[3].size()==n) break;
		
		int other1,other2;
		switch(next){
			case 1:{other1=2;other2=3;break;}
			case 2:{other1=3;other2=1;break;}
			case 3:{other1=1;other2=2;break;}
		}
		if(a[other1].empty()) 
			move(other2,other1);	
		else if(a[other2].empty())
			move(other1,other2);
		else
		{
			if(a[other1].top()<a[other2].top())
				move(other1,other2);
			else move(other2,other1);	
		}
	}
}
